package com.shenjinzheng.movie_ticket_app.activity

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.ViewModelProvider
import com.shenjinzheng.movie_ticket_app.databinding.ActivityMovieDetailBinding
import com.shenjinzheng.movie_ticket_app.model.Movie
import com.shenjinzheng.movie_ticket_app.viewmodel.MovieViewModel
import com.shenjinzheng.movie_ticket_app.viewmodel.MovieViewModelFactory
import com.shenjinzheng.movie_ticket_app.repository.MovieRepository
import com.shenjinzheng.movie_ticket_app.network.RetrofitClient

class MovieDetailActivity : AppCompatActivity() {

    private lateinit var binding: ActivityMovieDetailBinding
    private lateinit var movieViewModel: MovieViewModel

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        // 初始化 DataBinding
        binding = ActivityMovieDetailBinding.inflate(layoutInflater)
        setContentView(binding.root)

        // 获取电影 ID，从 Intent 中获取传递的电影数据
        val movie: Movie = intent.getParcelableExtra("movie") ?: return

        // 设置电影数据到视图
        binding.movie = movie

        // 设置返回按钮点击事件
        binding.ivBack.setOnClickListener {
            onBackPressed()  // 返回上一页
        }
    }
}